﻿<Window x:Class="UniversalEditor.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:universalEditor="clr-namespace:UniversalEditor"
        xmlns:openRelativeFileModule="clr-namespace:UniversalEditor.Modules.OpenRelativeFileModule"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:tabSwitchModule="clr-namespace:UniversalEditor.Modules.TabSwitchModule"
        xmlns:statusBarItems="clr-namespace:UniversalEditor.Base.StatusBarItems;assembly=UniversalEditor.Base"
        xmlns:menuBarItems="clr-namespace:UniversalEditor.Base.MenuBarItems;assembly=UniversalEditor.Base"
		xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
		xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:converters="clr-namespace:UniversalEditor.Base.Utils.Converters;assembly=UniversalEditor.Base"
        mc:Ignorable="d" d:DataContext="{x:Static universalEditor:DomainViewModel.Designer}"
        Title="{Binding WindowTitle}" Height="350" Width="525" DataContext="{x:Static universalEditor:App.DomainModel}" Icon="Resources/AppIcon.ico" Background="{x:Static SystemColors.ControlBrush}"
		DragEnter="MainWindow_OnDragEnter" DragOver="MainWindow_OnDragEnter" Drop="MainWindow_OnDrop" AllowDrop="True" 
		PreviewKeyDown="TabControl_OnPreviewKeyDown" PreviewKeyUp="TabControl_OnPreviewKeyUp">

	<Window.Resources>

		<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
		<SolidColorBrush x:Key="LineButtonBorderBrush" Color="#FF8693BD"/>

		<converters:BoolToBrushConverter x:Key="BoolToBrushConverter" PositiveBrush="#8E2FA8" NegativeBrush="DodgerBlue"/>
		
		<Style x:Key="OpenedTabMenuItemDefaultStyle" TargetType="MenuItem">
			<Setter Property="Header" Value="{Binding FileName}"/>
			<Setter Property="ToolTip" Value="{Binding DisplayFilePath}"/>
			<Setter Property="Command" Value="{Binding ElementName=tabControl, Path=DataContext.SelectEditorCommand}"/>
			<Setter Property="CommandParameter" Value="{Binding}"/>
		</Style>

		<Style x:Key="OpenedTabMenuItemSeparatorStyle" TargetType="MenuItem">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate>
						<Separator/>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

		<Style x:Key="OpenedTabMenuItemCommandStyle" TargetType="MenuItem">
			<Setter Property="Header" Value="{Binding Item1, Mode=OneTime}"/>
			<Setter Property="Command" Value="{Binding Item2, Mode=OneTime}"/>
			<Setter Property="Icon">
				<Setter.Value>
					<Image>
						<Image.Source>
							<BitmapImage UriSource="/UniversalEditor;component/Resources/windows.png" />
						</Image.Source>
					</Image>
				</Setter.Value>
			</Setter>
		</Style>

		<Style x:Key="TabMenuButtonStyle" TargetType="{x:Type MenuItem}">
			<Setter Property="Focusable" Value="False"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type MenuItem}">
						<Border Name="ButtonBorder" Margin="1">
							<Grid>
								<TextBlock FontFamily="Marlett" FontSize="16" Text="u" Margin="2"/>
								<Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
									<Border Name="SubmenuBorder" Margin="1" SnapsToDevicePixels="True" BorderBrush="{StaticResource LineButtonBorderBrush}" 
											Background="{x:Static SystemColors.ControlBrush}" BorderThickness="1">
										<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
									</Border>
								</Popup>
							</Grid>
						</Border>
						<ControlTemplate.Triggers>
							<Trigger SourceName="ButtonBorder" Property="IsMouseOver" Value="True">
								<Setter TargetName="ButtonBorder" Property="Background" Value="#55FFFFFF"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		
		<Style x:Key="TabMenuItem" TargetType="{x:Type MenuItem}">
			<Setter Property="Header" Value="{Binding Path=FileName}" />
			<Setter Property="ToolTip" Value="{Binding Path=FilePath}" />
			<Setter Property="IsCheckable" Value="true" />
			<Setter Property="IsChecked" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
		</Style>
		
		<Style TargetType="{x:Type TabControl}">
			<Setter Property="OverridesDefaultStyle" Value="True" />
			<Setter Property="SnapsToDevicePixels" Value="True" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type TabControl}">
						<Grid KeyboardNavigation.TabNavigation="None" Background="{x:Static SystemColors.ControlBrush}">
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto" />
								<RowDefinition Height="Auto" />
								<RowDefinition Height="*" />
							</Grid.RowDefinitions>
							<Border Name="TabPanelBorder" Visibility="{Binding OpenedEditorsCount, Converter={x:Static universalEditor:IntToVisibilityConverter.Default}}">
								<ScrollViewer SnapsToDevicePixels="True" Name="svTP" Grid.Row="0" CanContentScroll="False" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled">
									<ScrollViewer.Style>
										<Style TargetType="{x:Type ScrollViewer}">
											<Setter Property="Focusable" Value="False"/>
											<Setter Property="Template">
												<Setter.Value>
													<ControlTemplate>
														<Grid SnapsToDevicePixels="True">
															<Grid.ColumnDefinitions>
																<ColumnDefinition Width="*"/>
																<ColumnDefinition Width="Auto"/>
																<ColumnDefinition Width="Auto"/>
															</Grid.ColumnDefinitions>
															
															<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" VirtualizingStackPanel.IsVirtualizing="False" SnapsToDevicePixels="True" Grid.Column="0" Content="{TemplateBinding ScrollViewer.Content}" />
															<Grid Grid.Column="1" x:Name="Root" DataContext="{Binding SelectedEditor}" ToolTip="{Binding FilePath}">
																<Border x:Name="Border" Margin="0" BorderThickness="0" Background="#8E2FA8" TextBlock.Foreground="White">

																	<Border.Visibility>
																		<Binding Path="Invisible" Converter="{StaticResource BooleanToVisibilityConverter}"/>
																	</Border.Visibility>

																	<Grid>
																		<Grid.ColumnDefinitions>
																			<ColumnDefinition Width="*"/>
																			<ColumnDefinition Width="Auto"/>
																		</Grid.ColumnDefinitions>

																		<TextBlock Text="{Binding FileName}" HorizontalAlignment="Center" Grid.Column="0" VerticalAlignment="Center" Margin="6,2,6,2" >
																			<TextBlock.ContextMenu>
																				<ContextMenu>
																					<MenuItem Header="Reload" Command="{Binding RealoadCommand}">
																						<MenuItem.Icon>
																							<Image>
																								<Image.Source>
																									<BitmapImage UriSource="/UniversalEditor;component/Resources/reload.png" />
																								</Image.Source>
																							</Image>
																						</MenuItem.Icon>
																					</MenuItem>
																					<Separator/>
																					<MenuItem Header="Save" Command="{Binding SaveCommand}">
																						<MenuItem.Icon>
																							<Image>
																								<Image.Source>
																									<BitmapImage UriSource="/UniversalEditor;component/Resources/save.png" />
																								</Image.Source>
																							</Image>
																						</MenuItem.Icon>
																					</MenuItem>
																					<MenuItem Header="Save As" Command="{Binding SaveAsCommand}"/>
																					<MenuItem Header="Save Copy As" Command="{Binding SaveCopyAsCommand}"/>
																					<MenuItem Header="Save All" Command="{Binding SaveAllCommand}"/>
																					<Separator/>
																					<MenuItem Header="Close" CommandParameter="{Binding Editor}" Command="{Binding CloseCommand}">
																						<MenuItem.Icon>
																							<Image>
																								<Image.Source>
																									<BitmapImage UriSource="/UniversalEditor;component/Resources/delete.png" />
																								</Image.Source>
																							</Image>
																						</MenuItem.Icon>
																					</MenuItem>
																					<MenuItem Header="Close All" Command="{Binding CloseAllCommand}" />
																					<MenuItem Header="Close All But This" Command="{Binding CloseAllButThisCommand}" CommandParameter="{Binding Editor}"/>
																					<Separator/>
																					<MenuItem Header="Copy File Name" Command="{Binding CopyFileNameCommand}" />
																					<MenuItem Header="Copy File Path" Command="{Binding CopyFilePathCommand}" />
																					<MenuItem Header="Copy File Directory" Command="{Binding CopyFileDirectoryCommand}" />
																					<Separator/>
																					<MenuItem Header="Open File Location" Command="{Binding OpenFileLocationCommand}">
																						<MenuItem.Icon>
																							<Image>
																								<Image.Source>
																									<BitmapImage UriSource="/UniversalEditor;component/Resources/folder.png" />
																								</Image.Source>
																							</Image>
																						</MenuItem.Icon>
																					</MenuItem>
																				</ContextMenu>
																			</TextBlock.ContextMenu>
																		</TextBlock>

																		<Button Command="{Binding CloseCommand}" CommandParameter="{Binding Editor}" VerticalAlignment="Center" HorizontalAlignment="Center"
																						VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="0,2,6,2" Grid.Column="1" ToolTip="Close editor">
																			<Button.Template>
																				<ControlTemplate>
																					<Border x:Name="closeBorder" Background="Transparent">
																						<TextBlock FontFamily="Marlett" Text="r" Foreground="{x:Static SystemColors.ControlBrush}" Margin="2"/>
																					</Border>
																					<ControlTemplate.Triggers>
																						<Trigger SourceName="closeBorder" Property="IsMouseOver" Value="True">
																							<Setter TargetName="closeBorder" Property="Background" Value="#55FFFFFF"/>
																						</Trigger>
																					</ControlTemplate.Triggers>
																				</ControlTemplate>
																			</Button.Template>
																		</Button>

																	</Grid>
																</Border>
															</Grid>
															<Menu Grid.Column="2">
																<MenuItem Style="{StaticResource TabMenuButtonStyle}" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabControl}}, Path=Items}"
																				  ItemContainerStyle="{StaticResource TabMenuItem}">
																</MenuItem>
															</Menu>
															
														</Grid>
													</ControlTemplate>
												</Setter.Value>
											</Setter>
										</Style>
									</ScrollViewer.Style>
									<StackPanel Name="TabPanel" Orientation="Horizontal" IsItemsHost="true" KeyboardNavigation.TabIndex="1"/>
								</ScrollViewer>
							</Border>
							<Rectangle x:Name="rect" Grid.Row="1" Fill="{Binding SelectedEditor.Invisible, Converter={StaticResource BoolToBrushConverter}, FallbackValue=DodgerBlue}" Height="2"/>
							<Border x:Name="Border" Grid.Row="2" BorderThickness="0" CornerRadius="2" KeyboardNavigation.TabNavigation="None" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2" Background="White">
								<ContentPresenter x:Name="PART_SelectedContentHost" Margin="0" Content="{Binding SelectedEditor.Content}"/>
							</Border>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

		<Style TargetType="{x:Type TabItem}">
			<Setter Property="Background" Value="{x:Static SystemColors.ControlBrush}"/>
			<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type TabItem}">
						<Grid x:Name="Root" DataContext="{Binding}" ToolTip="{Binding FilePath}">
							<Border x:Name="Border" Margin="0" BorderThickness="0" Background="{TemplateBinding Background}">

								<Border.Visibility>
									<MultiBinding Converter="{x:Static universalEditor:TabVisibilityDetector.Default}">
										<Binding RelativeSource="{RelativeSource AncestorType=ScrollViewer}" />
										<Binding RelativeSource="{RelativeSource Self}"/>
										<Binding RelativeSource="{RelativeSource AncestorType=ScrollViewer}" Path="ViewportWidth"/>
										<Binding RelativeSource="{RelativeSource AncestorType=ScrollViewer}" Path="ExtentWidth"/>
										<Binding />
										<Binding RelativeSource="{RelativeSource AncestorType=StackPanel}" Path="ActualWidth"/>
									</MultiBinding>
								</Border.Visibility>
								
								<Grid>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="*"/>
										<ColumnDefinition Width="Auto"/>
									</Grid.ColumnDefinitions>
									
									<TextBlock Text="{Binding FileName}" HorizontalAlignment="Center" Grid.Column="0" VerticalAlignment="Center" Margin="6,2,6,2" >
										<TextBlock.ContextMenu>
											<ContextMenu>
												<MenuItem Header="Reload" Command="{Binding RealoadCommand}">
													<MenuItem.Icon>
														<Image>
															<Image.Source>
																<BitmapImage UriSource="/UniversalEditor;component/Resources/reload.png" />
															</Image.Source>
														</Image>
													</MenuItem.Icon>
												</MenuItem>
												<Separator/>
												<MenuItem Header="Save" Command="{Binding SaveCommand}">
													<MenuItem.Icon>
														<Image>
															<Image.Source>
																<BitmapImage UriSource="/UniversalEditor;component/Resources/save.png" />
															</Image.Source>
														</Image>
													</MenuItem.Icon>
												</MenuItem>
												<MenuItem Header="Save As" Command="{Binding SaveAsCommand}"/>
												<MenuItem Header="Save Copy As" Command="{Binding SaveCopyAsCommand}"/>
												<MenuItem Header="Save All" Command="{Binding SaveAllCommand}"/>
												<Separator/>
												<MenuItem Header="Close" CommandParameter="{Binding Editor}" Command="{Binding CloseCommand}">
													<MenuItem.Icon>
														<Image>
															<Image.Source>
																<BitmapImage UriSource="/UniversalEditor;component/Resources/delete.png" />
															</Image.Source>
														</Image>
													</MenuItem.Icon>
												</MenuItem>
												<MenuItem Header="Close All" Command="{Binding CloseAllCommand}" />
												<MenuItem Header="Close All But This" Command="{Binding CloseAllButThisCommand}" CommandParameter="{Binding Editor}"/>
												<Separator/>
												<MenuItem Header="Copy File Name" Command="{Binding CopyFileNameCommand}" />
												<MenuItem Header="Copy File Path" Command="{Binding CopyFilePathCommand}" />
												<MenuItem Header="Copy File Directory" Command="{Binding CopyFileDirectoryCommand}" />
												<Separator/>
												<MenuItem Header="Open File Location" Command="{Binding OpenFileLocationCommand}">
													<MenuItem.Icon>
														<Image>
															<Image.Source>
																<BitmapImage UriSource="/UniversalEditor;component/Resources/folder.png" />
															</Image.Source>
														</Image>
													</MenuItem.Icon>
												</MenuItem>
											</ContextMenu>
										</TextBlock.ContextMenu>
									</TextBlock>

									<Button Command="{Binding CloseCommand}" CommandParameter="{Binding Editor}" VerticalAlignment="Center" HorizontalAlignment="Center"
											VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="0,2,6,2" Grid.Column="1" ToolTip="Close editor">
										<Button.Template>
											<ControlTemplate>
												<Border x:Name="closeBorder" Background="Transparent">
													<TextBlock FontFamily="Marlett" Text="r" Foreground="{x:Static SystemColors.ControlBrush}" Margin="2"/>
												</Border>
												<ControlTemplate.Triggers>
													<Trigger SourceName="closeBorder" Property="IsMouseOver" Value="True">
														<Setter TargetName="closeBorder" Property="Background" Value="#55FFFFFF"/>
													</Trigger>
												</ControlTemplate.Triggers>
											</ControlTemplate>
										</Button.Template>
									</Button>
									
								</Grid>
							</Border>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger SourceName="Root" Property="IsMouseOver" Value="True">
								<Setter Property="Background" Value="RoyalBlue" />
								<Setter Property="Foreground" Value="White" />
							</Trigger>
							<Trigger Property="IsSelected" Value="True">
								<Setter Property="Background" Value="DodgerBlue" />
								<Setter Property="Foreground" Value="White" />
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

	</Window.Resources>

	<Window.InputBindings>
		<KeyBinding Gesture="CTRL+N" Command="{Binding NewCommand}" />
		<KeyBinding Gesture="CTRL+O" Command="{Binding OpenCommand}" />
		<KeyBinding Gesture="CTRL+S" Command="{Binding SaveCommand}"/>
		<KeyBinding Gesture="CTRL+ALT+S" Command="{Binding SaveAsCommand}"/>
		<KeyBinding Gesture="CTRL+F4" Command="{Binding CloseActiveCommand}"/>
		<KeyBinding Gesture="CTRL+SHIFT+N" Command="{Binding OpenRelativeFileCommand}"/>
		<KeyBinding Gesture="F1" Command="{Binding AboutCommand}"/>
	</Window.InputBindings>

	<Grid>

		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>

		<Menu SnapsToDevicePixels="False">
			
			<Menu.Resources>
				<converters:PathToImageConverter x:Key="PathToImageConverter" />
				
				<Style x:Key="NoneStyle" TargetType="MenuItem">
					<Setter Property="Visibility" Value="Collapsed"/>
				</Style>
				<Style x:Key="ListStyle" TargetType="MenuItem">
					<Setter Property="Header" Value="{Binding Name}"/>
					<Setter Property="Icon" Value="{Binding Icon, Converter={StaticResource PathToImageConverter}}"/>
					<Setter Property="ItemsSource" Value="{Binding SubItems}"/>
					<Setter Property="IsEnabled" Value="{Binding Enabled}"/>
					<Setter Property="Visibility" Value="{Binding Visible, Converter={StaticResource BooleanToVisibilityConverter}}"/>
				</Style>
				<Style x:Key="CommandStyle" TargetType="MenuItem">
					<Setter Property="Header" Value="{Binding Name}"/>
					<Setter Property="Icon" Value="{Binding Icon, Converter={StaticResource PathToImageConverter}}"/>
					<Setter Property="Command" Value="{Binding Command}"/>
					<Setter Property="IsEnabled" Value="{Binding Enabled}"/>
					<Setter Property="InputGestureText" Value="{Binding InputGestureText}"/>
				</Style>
				<Style x:Key="CheckStyle" TargetType="MenuItem">
					<Setter Property="Header" Value="{Binding Name}"/>
					<Setter Property="IsCheckable" Value="True"/>
					<Setter Property="IsChecked" Value="{Binding Checked}"/>
					<Setter Property="IsEnabled" Value="{Binding Enabled}"/>
				</Style>
				<Style x:Key="SeparatorStyle" TargetType="MenuItem">
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate>
								<Separator Style="{StaticResource {x:Static MenuItem.SeparatorStyleKey}}"/>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
				
				<menuBarItems:MenuStyleSelector x:Key="MenuStyleSelector" 
												NoneStyle="{StaticResource NoneStyle}"
												ListStyle="{StaticResource ListStyle}"
												CheckStyle="{StaticResource CheckStyle}"
												CommandStyle="{StaticResource CommandStyle}"
												SeparatoeStyle="{StaticResource SeparatorStyle}"/>
				
			</Menu.Resources>
			
			<MenuItem Header="File">
				<MenuItem Header="New" Command="{Binding NewCommand}" InputGestureText="Ctrl+N">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/add.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Open..." Command="{Binding OpenCommand}" InputGestureText="Ctrl+O">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/open.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Open Recent" ItemsSource="{Binding RecentFiles}">
					<MenuItem.ItemContainerStyle>
						<Style TargetType="MenuItem">
							<Setter Property="Header" Value="{Binding}"/>
							<Setter Property="Command" Value="{Binding ElementName=tabControl, Path=DataContext.OpenSpecifiedFileCommand}"/>
							<Setter Property="CommandParameter" Value="{Binding}"/>
						</Style>
					</MenuItem.ItemContainerStyle>
				</MenuItem>
				<Separator/>
				<MenuItem Header="Save" Command="{Binding SaveCommand}" InputGestureText="Ctrl+S">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/save.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Save As..." Command="{Binding SaveAsCommand}" InputGestureText="Ctrl+Alt+S"/>
				<MenuItem Header="Save Copy As..." Command="{Binding SaveCopyAsCommand}"/>
				<MenuItem Header="Save All" Command="{Binding SaveAllCommand}"/>
				<Separator/>
				<MenuItem Header="Reload" Command="{Binding RealoadCommand}">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/reload.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
				<Separator/>
				<MenuItem Header="Close" Command="{Binding CloseActiveCommand}" InputGestureText="Ctrl+F4">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/delete.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Close All" Command="{Binding CloseAllCommand}"/>
				<MenuItem Header="Close All But This" Command="{Binding CloseAllButActiveCommand}"/>
				<Separator/>
				<MenuItem Header="Exit" Command="{Binding ExitCommand}" InputGestureText="Alt+F4">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/exit.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
			</MenuItem>
			<MenuItem Header="Edit">
				<MenuItem Header="Undo" Command="{Binding SelectedEditor.Editor.UndoCommand}" InputGestureText="Ctrl+Z">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/Redo.png" Rotation="Rotate180"/>
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Redo" Command="{Binding SelectedEditor.Editor.RedoCommand}" InputGestureText="Ctrl+Y">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/Redo.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
				<Separator/>
				<MenuItem Header="Cut" Command="{Binding SelectedEditor.Editor.CutCommand}" InputGestureText="Ctrl+X"/>
				<MenuItem Header="Copy" Command="{Binding SelectedEditor.Editor.CopyCommand}" InputGestureText="Ctrl+C"/>
				<MenuItem Header="Paste" Command="{Binding SelectedEditor.Editor.PasteCommand}" InputGestureText="Ctrl+V"/>
				<MenuItem Header="Delete" Command="{Binding SelectedEditor.Editor.DeleteCommand}" InputGestureText="Del"/>
				<MenuItem Header="Select All" Command="{Binding SelectedEditor.Editor.SelectAllCommand}" InputGestureText="Ctrl+A"/>
				<Separator/>
				<MenuItem Header="Copy File Name" Command="{Binding CopyFileNameCommand}" />
				<MenuItem Header="Copy File Path" Command="{Binding CopyFilePathCommand}" />
				<MenuItem Header="Copy File Directory" Command="{Binding CopyFileDirectoryCommand}" />
			</MenuItem>
			<MenuItem Header="Content Type" ItemsSource="{Binding Editors}" Visibility="{Binding HasOpenedEditor, Converter={StaticResource BooleanToVisibilityConverter}}">
				<MenuItem.ItemContainerStyle>
					<Style TargetType="MenuItem">
						<Setter Property="Header" Value="{Binding DisplayName}"/>
						<Setter Property="Command" Value="{Binding ElementName=tabControl, Path=DataContext.ContentTypeChangeCommand}"/>
						<Setter Property="IsChecked" Value="{Binding IsChecked}"/>
						<Setter Property="CommandParameter" Value="{Binding Format}"/>
					</Style>
				</MenuItem.ItemContainerStyle>
			</MenuItem>
			
			<MenuItem DataContext="{Binding SelectedEditor.Editor.Menu1}" Style="{StaticResource ListStyle}" ItemContainerStyleSelector="{StaticResource MenuStyleSelector}" Visibility="Collapsed"/>
			<MenuItem DataContext="{Binding SelectedEditor.Editor.Menu2}" Style="{StaticResource ListStyle}" ItemContainerStyleSelector="{StaticResource MenuStyleSelector}" Visibility="Collapsed"/>
			<MenuItem DataContext="{Binding SelectedEditor.Editor.Menu3}" Style="{StaticResource ListStyle}" ItemContainerStyleSelector="{StaticResource MenuStyleSelector}" Visibility="Collapsed"/>
			<MenuItem DataContext="{Binding SelectedEditor.Editor.Menu4}" Style="{StaticResource ListStyle}" ItemContainerStyleSelector="{StaticResource MenuStyleSelector}" Visibility="Collapsed"/>
			<MenuItem DataContext="{Binding SelectedEditor.Editor.Menu5}" Style="{StaticResource ListStyle}" ItemContainerStyleSelector="{StaticResource MenuStyleSelector}" Visibility="Collapsed"/>
			
			<MenuItem Header="Settings">
				<MenuItem Header="Options..." Command="{Binding OptionsCommand}">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/settings.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
			</MenuItem>
			<MenuItem Header="Windows" ItemsSource="{Binding WindowsMenuItemContent}" Visibility="{Binding HasOpenedEditor, Converter={StaticResource BooleanToVisibilityConverter}}">
				<MenuItem.ItemContainerStyleSelector>
						<universalEditor:WindowsMenuItemStyleSelector/>
				</MenuItem.ItemContainerStyleSelector>
			</MenuItem>
			<MenuItem Header="Help">
				<MenuItem Header="Documentation" Command="{Binding DocumentationCommand}">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/info.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
				<Separator/>
				<MenuItem Header="Check for update" Command="{Binding UpdateCommand}">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/download.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="Website" Command="{Binding WebsiteCommand}">
					<MenuItem.Icon>
						<Image>
							<Image.Source>
								<BitmapImage UriSource="/UniversalEditor;component/Resources/web.png" />
							</Image.Source>
						</Image>
					</MenuItem.Icon>
				</MenuItem>
				<MenuItem Header="About..." Command="{Binding AboutCommand}" InputGestureText="F1"/>
			</MenuItem>
		</Menu>

		<!--<ToolBarPanel  Grid.Row="1" Orientation="Horizontal" Background="Transparent">
			<ToolBarPanel.Resources>
				<Style TargetType="ToolBar">
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="ToolBar">
								<StackPanel Orientation="Horizontal" IsItemsHost="True"/>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
					<Setter Property="Background" Value="Transparent"/>
					<Setter Property="OverflowMode" Value="Never"/>
				</Style>
			</ToolBarPanel.Resources>
			
			<ToolBar>
				<Button ToolTip="New file" Command="{Binding NewCommand}">
					<Image Width="16" Height="16">
						<Image.Source>
							<BitmapImage UriSource="/UniversalEditor;component/Resources/add.png" />
						</Image.Source>
					</Image>
				</Button>
				<Button ToolTip="Open file..." Command="{Binding OpenCommand}">
					<Image Width="16" Height="16">
						<Image.Source>
							<BitmapImage UriSource="/UniversalEditor;component/Resources/open.png" />
						</Image.Source>
					</Image>
				</Button>
				<Button ToolTip="Save file" Command="{Binding SaveCommand}">
					<Image Width="16" Height="16">
						<Image.Source>
							<BitmapImage UriSource="/UniversalEditor;component/Resources/save.png" />
						</Image.Source>
					</Image>
				</Button>
				<Button ToolTip="Reload" Command="{Binding RealoadCommand}">
					<Image>
						<Image.Source>
							<BitmapImage UriSource="/UniversalEditor;component/Resources/reload.png" />
						</Image.Source>
					</Image>
				</Button>
				<Button ToolTip="Close" Command="{Binding CloseActiveCommand}">
					<Image>
						<Image.Source>
							<BitmapImage UriSource="/UniversalEditor;component/Resources/delete.png" />
						</Image.Source>
					</Image>
				</Button>
			</ToolBar>
			<ToolBar>
				<Separator/>
				<Button ToolTip="Undo" Command="{Binding SelectedEditor.Editor.UndoCommand}">
					<Image>
						<Image.Source>
							<BitmapImage UriSource="/UniversalEditor;component/Resources/Redo.png" Rotation="Rotate180"/>
						</Image.Source>
					</Image>
				</Button>
				<Button ToolTip="Redo" Command="{Binding SelectedEditor.Editor.RedoCommand}">
					<Image>
						<Image.Source>
							<BitmapImage UriSource="/UniversalEditor;component/Resources/Redo.png" />
						</Image.Source>
					</Image>
				</Button>
			</ToolBar>
		</ToolBarPanel>-->

		<TabControl x:Name="tabControl" Grid.Row="2" SelectionChanged="TabControl_OnSelectionChanged" KeyboardNavigation.TabNavigation="None" 
					PreviewKeyDown="TabControl_OnPreviewKeyDown" PreviewKeyUp="TabControl_OnPreviewKeyUp"
					ItemsSource="{Binding OpenedEditors}" SelectedItem="{Binding SelectedEditor}"/>

		<openRelativeFileModule:OpenRelativeFileView DataContext="{Binding OpenRelativeFileViewModel}" Grid.RowSpan="3" VerticalAlignment="Center" HorizontalAlignment="Center" Placement="Center"/>
		<tabSwitchModule:TabSwitchView DataContext="{Binding TabSwitchViewModel}" Grid.RowSpan="3" VerticalAlignment="Center" HorizontalAlignment="Center" Placement="Center"/>

		<Grid Grid.Row="3" Background="DodgerBlue" MinHeight="10">
			<Grid.Resources>
				<DataTemplate DataType="{x:Type statusBarItems:StatusTextItem}">
					<TextBlock Foreground="White" Text="{Binding Text}" Width="{Binding Width}" MinWidth="{Binding MinWidth}" Margin="5,2,5,2"/>
				</DataTemplate>
			</Grid.Resources>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="Auto"/>
				<ColumnDefinition Width="Auto"/>
			</Grid.ColumnDefinitions>

			<ItemsControl Grid.Column="0" ItemsSource="{Binding StatusLeftElements}">
				<ItemsControl.ItemsPanel>
					<ItemsPanelTemplate>
						<StackPanel Orientation="Horizontal" IsItemsHost="True"/>
					</ItemsPanelTemplate>
				</ItemsControl.ItemsPanel>
			</ItemsControl>

			<ItemsControl Grid.Column="1" ItemsSource="{Binding StatusRightElements}">
				<ItemsControl.ItemsPanel>
					<ItemsPanelTemplate>
						<StackPanel Orientation="Horizontal" IsItemsHost="True"/>
					</ItemsPanelTemplate>
				</ItemsControl.ItemsPanel>
			</ItemsControl>

			<TextBlock Grid.Column="2" Margin="0,2,0,2"/>
			
		</Grid>
		
	</Grid>
</Window>
